package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "套餐管理")
@RequestMapping("/admin/setmeal")
public class SetmealContrller {
    @Autowired
    private SetmealService setmealService;

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/page")
    public Result page(SetmealPageQueryDTO dto){
        log.info("分页查询"+dto);
        return setmealService.page(dto);
    }

    /**
     * 根据id查询数据
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<SetmealVO> getbyId(@PathVariable Long id){
        log.info("根据id查询数据"+id);
        return setmealService.getbyId(id);
    }
    /**
     * 修改套餐
     * @param dto
     * @return
     */
    @PutMapping
    public Result updateSetmeal(@RequestBody SetmealDTO dto){
        log.info("修改套餐"+dto);
        return setmealService.updateSetmeal(dto);
    }
    /**
     * 新增套餐
     * @param dto
     * @return
     */
    @PostMapping
    public Result insetSetmeal(@RequestBody SetmealDTO dto){
        log.info("新增套餐"+dto);
        return setmealService.insetSetmeal(dto);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping
    public Result deleteSetmeal(@RequestParam List<Long> ids){
        log.info("批量删除"+ids);
        return setmealService.deleteSetmeal(ids);
    }
}
